#ifndef DIALOGPROGRAM_H
#define DIALOGPROGRAM_H

#include <QDialog>
#include <QTableWidgetItem>

#include "frequencelist.h"
#include "programlist.h"


namespace Ui {
class DialogProgram;
}

class DialogProgram : public QDialog
{
    Q_OBJECT

public:
    explicit DialogProgram(QWidget *parent = 0);
    ~DialogProgram();

    void setFreqList(tv::FrequenceList& freqList);

    void setProgramList(tv::ProgramList& programList);

    tv::ProgramList& getProgramList();

private slots:
    void on_pushButtonAdd_clicked();

    void on_pushButtonDelete_clicked();

    void on_pushButtonEdit_clicked();

    void on_pushButtonImport_clicked();

    void on_pushButtonExport_clicked();

    void on_tableWidget_currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous);


    void on_comboBoxFreqNum_currentIndexChanged(int index);

    void on_comboBoxFreqName_currentIndexChanged(int index);

protected:
    enum Role
    {
        kNumRole = Qt::UserRole + 1
    };

    void setProgram(int row, const tv::Program& program);

    void appendProgram(const tv::Program& program);

    void fillNumCombo();

    void showProgram(int row);
    void showProgram(const tv::Program& program);

    void updateProgram(int row);

    void refreshTable();

    void fillFreqCombo();

private:
    Ui::DialogProgram *ui;

private:
    tv::FrequenceList  m_freqList;
    tv::ProgramList    m_programList;

};

#endif // DIALOGPROGRAM_H
